<template>
  <div class="ma-content-block lg:flex justify-between">
    <sa-table ref="crudRef" :options="options" :columns="columns" :searchForm="searchForm"  @resetSearch="resetSearch">
      <template #state_text="{ record }">
        <a-tag color="green" v-if="record.state == 1">{{ record.state_text }}</a-tag>
        <a-tag color="magenta" v-else>{{ record.state_text }}</a-tag>
      </template>
    </sa-table>
    <!-- 编辑表单 -->
    <edit-form ref="editRef" @success="refresh" />

  </div>
</template>

<script setup>
import { onMounted, ref, reactive, computed, watch } from 'vue'
import AsApi from '@/api/system/afterSale'
import { Message } from '@arco-design/web-vue'
import { throttle } from 'lodash';
import SaTable from '@cps/sa-table/index.vue'
import EditForm from './edit.vue'
import tool from '@/utils/tool'
const crudRef = ref()
const editRef = ref()
const searchForm = ref({
 
})
const options = reactive({
  api: AsApi.aftersale_list,//表格数据接口
  operationColumnWidth: 120,//操作欄
  showSearch: false,
  columnAlign: 'center',
  pageSimple: false,//是否展示操作欄有 以及工具欄
  isTreeTable: false,
  add: {//頂部新增按鈕
    show: false,
    auth: ['/core/menu/save'],
    func: async () => {
      editRef.value?.open()
    },
  },
  edit: {//操作欄编辑按鈕
    show: true,
    auth: ['/core/menu/update'],
    func: async (record) => {
      editRef.value?.open('edit', record)
      editRef.value?.setFormData(record)
    },
  },
  isExpand: false,//展開所有子樹
})

const columns = reactive([
  { title: 'ID', dataIndex: 'id', width: 100 },
  { title: '状态', dataIndex: 'state_text', width: 150 },
  { title: '代理名字', dataIndex: 'true_name', width: 150 },
  { title: '收获名称', dataIndex: 'address_true_name', width: 150 },
  { title: '服务地区', dataIndex: 'area_text', width: 180 },
  { title: '电话', dataIndex: 'mobile', width: 180 },
  { title: '连接仓库', dataIndex: 'room_str', width: 200 },
  { title: '地址', dataIndex: 'address', width: 200 },
  { title: '创建时间', dataIndex: 'create_time', width: 180 },
])
const initPage = async () => {

}
const refresh = async () => {
  crudRef.value?.refresh()
}
const paramsData = ref({})
const getParams = async () => {
  // const { data } = await AsApi.suopei_list_params()
  // paramsData.value = { ...data }
  // paramsData.value.stockroom_list.unshift({ name: '全部', id: 99 })
}
const resetSearch = () => {
  searchForm.value.create_time = ''
}



onMounted(async () => {
  initPage()
  refresh()
  getParams()
})
</script>

<style scoped>
.icon {
  width: 1em;
}
</style>